﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace YArchitech.Public.ExcelToView
{
	internal static class Utility
	{
		internal static string GetNoneWhiteString(string input)
		{
			return Regex.Replace(input, " ", string.Empty);
		}

		internal static string ConvertToExcelTitle(int n)
		{
			List<int> list = new List<int>();
			int i;
			for (i = n + 1; i > 26; i /= 26)
			{
				if (i % 26 == 0)
				{
					list.Add(26);
					i -= 26;
				}
				else
				{
					list.Add(i % 26);
					i -= i % 26;
				}
			}
			list.Add(i);
			list.Reverse();
			StringBuilder stringBuilder = new StringBuilder();
			foreach (int num in list)
			{
				stringBuilder.Append((char)(num - 1 + 65));
			}
			return stringBuilder.ToString();
		}
	}
}
